<template>
  <div class="auth main-v-center main-h-center">
    <div class="auth-container">
      <div class="card">
        <header class="auth-header">
          <div class="auth-title">
            <span style="font-size: 30px;font-weight:700;margin-right:10px;color:#32CD32">HiGame</span>
            <span style="font-size: 27px;font-weight: 400;">后台管理系统</span>
          </div>
        </header>
        <div class="auth-content">
          <div class="form-group">
            <label for="username">用户名：</label>
            <input
              type="text"
              class="form-control underlined"
              name="username"
              id="username"
              placeholder="请输入用户名"
              required
              v-model="username"
              @keyup.enter="handleLogin"
            />
          </div>
          <div class="form-group">
            <label for="password">登录密码：</label>
            <input
              type="password"
              class="form-control underlined"
              name="password"
              id="password"
              placeholder="请输入登录密码"
              required
              v-model="password"
              @keyup.enter="handleLogin"
            />
          </div>
          <div class="form-group" style="margin-top:40px;">
            <button type="submit" class="btn btn-block btn-primary" @click="handleLogin">登录</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      username: "",
      password: ""
    };
  },
  methods: {
    handleLogin() {
      this.$store
        .dispatch("user_login", {
          username: this.username,
          password: this.password
        })
        .then(res => {
          if (res.code != 200) {
            this.$message.error(res.msg);
          } else {
            this.$router.push({ name: "report", query: {} });
          }
        })
        .catch(err => {
          this.$message.error(err);
        });
    }
  }
};
</script>
<style scoped>
*,
*::before,
*::after {
  box-sizing: border-box;
}

.logo {
  display: inline-block;
  width: 45px;
  height: 25px;
  margin-right: 10px;
  margin-bottom: -3px;
  position: relative;
}

label,
.control-label {
  font-weight: 600;
}

label {
  display: inline-block;
  margin-bottom: 0.5rem;
}

.auth {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: #3a4651;
}

.auth-container {
  width: 450px;
  min-height: 330px;
}

.auth-container .auth-header {
  text-align: center;
  border-bottom: 1px solid #32CD32;
}

.auth-container .auth-title {
  color: #97a4b1;
  padding: 20px;
  line-height: 30px;
  font-size: 26px;
  font-weight: 600;
  margin: 0;
}

.auth-container .auth-content {
  padding: 30px 50px;
  min-height: 260px;
}

.auth-container .forgot-btn {
  line-height: 28px;
}

.auth-container .checkbox label {
  padding: 0;
}

.auth-container .checkbox a {
  vertical-align: text-top;
}

.auth-container .checkbox span {
  color: #4f5f6f;
}

@media (max-width: 767.98px) {
  .auth-container {
    width: 100%;
    position: relative;
    left: 0;
    top: 0;
    -webkit-transform: inherit;
    transform: inherit;
    margin: 0;
    margin-bottom: 10px;
  }

  .auth-container .auth-content {
    padding: 30px 25px;
  }
}

.form-group {
  margin-bottom: 1rem;
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #495057;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control.underlined:focus {
  outline: none !important;
  border-bottom: 1px solid #32CD32;
}

.form-control.underlined {
  padding-left: 0;
  padding-right: 0;
  border-radius: 0;
  border: none;
  border-radius: 0;
  -webkit-box-shadow: none;
  box-shadow: none;
  border-bottom: 1px solid #d7dde4;
}

.form-control.underlined::-webkit-input-placeholder {
  /* WebKit browsers */
  color: #d7dde4;
  font-style: italic;
}

.form-control.underlined:-moz-placeholder {
  /* Mozilla Firefox 4 to 18 */
  color: #d7dde4;
  font-style: italic;
}

.form-control.underlined::-moz-placeholder {
  /* Mozilla Firefox 19+ */
  color: #d7dde4;
  font-style: italic;
}

.form-control.underlined:-ms-input-placeholder {
  /* Internet Explorer 10+ */
  color: #d7dde4;
  font-style: italic;
}

.btn:not(:disabled):not(.disabled) {
  cursor: pointer;
}

.btn.btn-primary:hover {
  color: #ffffff;
}

.btn.btn-primary {
  color: #fff;
  background-color: #32CD32;
  border-color: #32CD32;
}

.btn:hover {
  color: #ffffff;
  background-color: rgb(44, 172, 44);
}

.btn-block {
  display: block;
  width: 100%;
}

.btn-primary {
  color: #fff;
  background-color: #32CD32;
  border-color: #32CD32;
}

.btn {
  background-image: none;
  border-radius: 0;
  margin-bottom: 5px;
  line-height: 1.2;
  display: inline-block;
  font-weight: 400;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  border: 1px solid transparent;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
    border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  border-radius: 8px;
}

.card {
  background-color: #fff;
  -webkit-box-shadow: 1px 1px 5px rgba(126, 142, 159, 0.1);
  box-shadow: 1px 1px 5px rgba(126, 142, 159, 0.1);
  margin-bottom: 10px;
  border-radius: 0;
  border: none;
  position: relative;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-color: #fff;
  background-clip: border-box;
  border: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: 8px;
  -moz-box-shadow: 0px 0px 20px #7a7a7a;
  -webkit-box-shadow: 0px 0px 20px #7a7a7a;
  box-shadow: 0px 0px 20px #7a7a7a;
}
</style>

